<?php
#####################################################
# RWCARDS - Joomla E-Cards Componment!
# Copyright (C) 2004/2005 by Ralf Weber
# Company    : LoadBrain
# Homepage   : www.weberr.de
# Version    : 2.1.0
# Date       : 23/11/2005
# License    : Released under GPL
######################################################

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

if ( !defined('_RWCARDS_LANG_INCLUDED') ) 
{
  	if ( file_exists($mosConfig_absolute_path . "/components/com_rwcards/language/" . $mosConfig_lang . ".php") )
	{
    	include_once($mosConfig_absolute_path . "/components/com_rwcards/language/" . $mosConfig_lang . ".php");
  	}
	else 
	{
    	include_once($mosConfig_absolute_path . "/components/com_rwcards/language/english.php");
	}
}

class rwcards_categories_html
{
/**
* Displays Categories
*
* Lists all the categories
*/	
	
	function RWCardsListCategories( &$rows, &$pageNav, $search, $option ) 
	{
    global $mosConfig_live_site, $my;
?>
<br />

<div align="center" class="centermain">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
	<td><img src="./components/com_rwcards/images/admin_category_over.jpg" alt="<?php echo _ADMIN_RWCARDS_MANAGE_CATEGORIES; ?>" width="47" height="47" border="0"></td>
	<th><?php echo _ADMIN_RWCARDS_MANAGE_CATEGORIES; ?></td>
	</tr>
</table>
<br />
	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr> 
      <td width="100%" class="sectionname">&nbsp;</td>
			<td nowrap="nowrap"><?php echo _ADMIN_RWCARDS_DISPLAY; ?> #</td>
			<td> <?php echo $pageNav->writeLimitBox(); ?> </td>
			<td><?php echo _ADMIN_RWCARDS_SEARCH; ?>:</td>
			<td><input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" /></td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th width="20" nowrap="nowrap">#</th>
			<th width="20" class="title" nowrap="nowrap"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>
			<th width="70%" class="title" nowrap="nowrap"><?php echo _ADMIN_RWCARDS_CATEGORY; ?></th>
			<th width="50" class="title" nowrap="nowrap"><?php echo _ADMIN_RWCARDS_PUBLISHED; ?></th>
			<th width="50" colspan="2" nowrap="nowrap"><?php echo _ADMIN_RWCARDS_REORDER; ?></th>
		</tr>
<?php
		$k = 0;
		for ($i=0, $n=count($rows); $i < $n; $i++) 
		{
			$row = $rows[$i];
      		$img = $row->published ? 'tick.png' : 'publish_x.png';
			$task = $row->published ? 'unpublish' : 'publish';
			$title = $row->published ? _ADMIN_RWCARDS_CATEGORY_PUBLISHED : _ADMIN_RWCARDS_CATEGORY_UNPUBLISHED;
      // same like mosCommonHTML::CheckedOutProcessing( $row, $i );
      	if ( $row->checked_out ) 
		{
			  $checked = mosCommonHTML::checkedOut( $row );
  		} else 
		{
  			$checked = mosHTML::idBox( $i, $row->id, ($row->checked_out && $row->checked_out != $my->id ), 'pid' );
  		}

      $link = 'index2.php?option=com_rwcards&hidemainmenu=1&task=edit_category&pid[]='.$row->id;
?>
		<tr class="<?php echo "row$k"; ?>"> 
			<td><?php echo $i+1+$pageNav->limitstart; ?></td>
			<td><?php echo $checked; ?></td>
			<td><?php 
      if ( $row->checked_out && ( $row->checked_out != $my->id ) ) 
	  {
        echo $row->category_kategorien_name;
      }
      else 
	  {
        ?>
        <a href="<?php echo $link; ?>" title="<?php echo _ADMIN_RWCARDS_CATEGORY_EDIT; ?>"><?php echo $row->category_kategorien_name; ?></a>
        <?php
      }
      ?></td>
		  <td align="center"><a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')"><img src="images/<?php echo $img;?>" width="12" height="12" border="0" alt="" title="<?php echo $title; ?>" /></a></td>
      <td align="center">
	<?php		
	if ($i > 0 || ($i+$pageNav->limitstart > 0)) 
	{ ?>
        <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>','orderup')">
        <img src="images/uparrow.png" width="12" height="12" border="0" title="<?php echo _ADMIN_RWCARDS_MOVE_UP; ?>">
        </a>
    <?php		
	} 
	?>
      </td>
      <td align="center">
	<?php		
	if ($i < $n-1 || $i+$pageNav->limitstart < $pageNav->total-1) 
	{ ?>
        <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>','orderdown')">
        <img src="images/downarrow.png" width="12" height="12" border="0" title="<?php echo _ADMIN_RWCARDS_MOVE_DOWN; ?>">
        </a>
    <?php		
	} 
	?>
      </td>
		</tr>
    <?php 
	$k = 1 - $k;
	}
	 ?>
    <tr> 
      <th align="center" colspan="10"> <?php echo $pageNav->writePagesLinks(); ?></th>
    </tr>
    <tr> 
      <td align="center" colspan="10"> <?php echo $pageNav->writePagesCounter(); ?></td>
    </tr>
  </table>
  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="categories" />
  <input type="hidden" name="boxchecked" value="0" />
  <input type="hidden" name="hidemainmenu" value="0" />
</form>
<?php
  }

/**
* New / Edit Category
*/	
	function RWCardsEditCategory( &$row, $option, &$olist ) 
	{

		mosMakeHtmlSafe( $row, ENT_QUOTES, 'description' );
?>
	<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			// do field validation
			if (form.category_kategorien_name.value == ""){
				alert( "<?php echo _ADMIN_RWCARDS_PROVIDE_NAME; ?>" );
			} else {
				submitform( pressbutton );
			}
		}
	</script>
<table border="0" cellspacing="0" cellpadding="5">
<tr>
	<td><img src="./components/com_rwcards/images/admin_category_over.jpg" alt="<?php echo _ADMIN_RWCARDS_MANAGE_CATEGORIES; ?>" width="47" height="47" border="0"></td>
	<th><?php echo ( $row->id ? _ADMIN_RWCARDS_EDIT_CATEGORY : _ADMIN_RWCARDS_ADD_NEW_CATEGORY );?></td>
	</tr>
</table>
<br />
	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr> 
			<td width="15%" align="right"><?php echo _ADMIN_RWCARDS_CATEGORY; ?>:</td>
			<td width="85%" colspan="2"><input class="inputbox" type="text" name="category_kategorien_name" size="50" maxlength="100" value="<?php echo $row->category_kategorien_name; ?>" /></td>
		<tr> 
		<tr> 
			<td width="15%" align="right" valign="top"><?php echo _ADMIN_RWCARDS_CATEGORY_DESCRIPTION; ?>:</td>
			<td width="85%" colspan="2"><textarea class="inputbox" name="category_description"><?php echo $row->category_description; ?></textarea></td>
		<tr>
		<tr>
      <td valign="top" align="right"><?php echo _ADMIN_RWCARDS_ORDERING ?>:</td>
      <td> <?php echo $olist; ?> </td>
    </tr>
		<tr> 
			<td colspan="2">&nbsp;</td>
		</tr>
	</table>
	<input type="hidden" name="option" value="<?php echo $option; ?>" />
	<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
	<input type="hidden" name="task" value="" />
	</form>
<?php
	}

}